
// void __stdcall CopyBaseplaneToFrameBuffer(
//    UInt16 * pu16Baseplane, UInt16 * pu16FrameBuffer, Int32 n32Size);

//00000910 <__ZN8CDisplay26CopyBaseplaneToFrameBufferEv>:
//
//Void CDisplay::CopyBaseplaneToFrameBuffer()
//{
//     910:	e1a0c00d 	mov	ip, sp
//     914:	e92dd800 	stmdb	sp!, {fp, ip, lr, pc}
//     918:	e24cb004 	sub	fp, ip, #4	; 0x4
//    // RGBT555 to RGB565
//    UInt16 * pu16Baseplane = (UInt16*)m_Baseplane;
//     91c:	e590c008 	ldr	ip, [r0, #8]
//    UInt16 * pu16FrameBuffer = (UInt16*)m_frameBuffer;
//     920:	e5900018 	ldr	r0, [r0, #24]
//    Int32 n32Size = SCREEN_WIDTH * SCREEN_HEIGHT;
//
//    while (n32Size--) {
//        *(pu16FrameBuffer) = ColorRGBT555ToRGB565(*pu16Baseplane);
//        pu16Baseplane++;
//        pu16FrameBuffer++;
//     924:	e3a01b5d 	mov	r1, #95232	; 0x17400
//     928:	e2811fbf 	add	r1, r1, #764	; 0x2fc
//     92c:	e2811003 	add	r1, r1, #3	; 0x3
//     930:	e3a0ecff 	mov	lr, #65280	; 0xff00
//     934:	e28ee0e0 	add	lr, lr, #224	; 0xe0
//     938:	e0dc30b2 	ldrh	r3, [ip], #2
//     93c:	e003200e 	and	r2, r3, lr
//     940:	e203301f 	and	r3, r3, #31	; 0x1f
//     944:	e1833082 	orr	r3, r3, r2, lsl #1
//     948:	e0c030b2 	strh	r3, [r0], #2
//     94c:	e2411001 	sub	r1, r1, #1	; 0x1
//     950:	e3710001 	cmn	r1, #1	; 0x1
//     954:	1afffff7 	bne	938 <__ZN8CDisplay26CopyBaseplaneToFrameBufferEv+0x28>
//    }
//}
//     958:	e89da800 	ldmia	sp, {fp, sp, pc}


#include <asm.h>

.global C_SYMBOL(CopyBaseplaneToFrameBuffer)

C_SYMBOL(CopyBaseplaneToFrameBuffer):

    STMFD	SP!, {R4-R5, LR}    // store registers and LR

    MOV     R5, #65280          // 0xFF00
    ADD	    R5, R5, #224	    // 0xE0

CopyBaseplaneToFrameBuffer_Loop:

    LDRH    R3, [R0], #2
    AND     R4, R3, R5
    AND     R3, R3, #31         // 0x1F
    ORR     R3, R3, R4, LSL #1
    STRH    R3, [R1], #2

    SUB     R2, R2, #1
    CMN     R2, #1
    BNE     CopyBaseplaneToFrameBuffer_Loop

    LDMFD	SP!, {R4-R5, PC}    // restore registers and return
